import 'dart:convert';
import 'dart:io';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_aygsh/base/Constant.dart';
import 'package:flutter_aygsh/http/Api.dart';
import 'package:flutter_aygsh/liz_mine/address/MyAddress.dart';
import 'package:flutter_aygsh/liz_mine/order/OrderPage.dart';
import 'package:flutter_aygsh/liz_mine/set/InviteFriend.dart';
import 'package:flutter_aygsh/liz_mine/set/MyReceipt.dart';
import 'package:flutter_aygsh/liz_mine/set/MyTeamMarket.dart';
import 'package:flutter_aygsh/liz_mine/set/SystemSet.dart';
import 'package:flutter_aygsh/liz_mine/set/TeamOrderPage.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_easyrefresh/material_header.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../base/application.dart';
import '../event/LoginEvent.dart';
import '../http/HttpUtil.dart';
import '../liz_home/point/point_page.dart';
import '../liz_mine/collect/Collect.dart';
import '../liz_mine/coupon/MyCoupon.dart';
import '../liz_mine/fund/TXPage.dart';
import '../liz_mine/set/ArticleDetail.dart';
import '../liz_mine/set/Form.dart';
import '../liz_mine/set/InformNews.dart';
import '../liz_mine/set/KeFu.dart';
import '../liz_mine/set/MyEarn.dart';
import '../liz_mine/set/MyShop.dart';
import '../liz_mine/set/MySign.dart';
import '../liz_mine/set/MyWallet.dart';
import '../liz_mine/set/PointList.dart';
import '../shopper/BecomeShopper.dart';
import '../util/AppSaveInfoUtil.dart';
import '../util/SignUtil.dart';
import 'order/LocalNavWebWidget.dart';
import 'order/OrderComment.dart';

class MinePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return MineFragmentState();
  }
}

class MineFragmentState extends State<MinePage> with WidgetsBindingObserver {
  EasyRefreshController _controller = new EasyRefreshController();
  int loginStatusCode = 0;
  bool isVip = false;

  String group_name = "", userName = "", avatar;
  String code = "暂无";
  String balance = "0", group_id = "1";
  String token = "";
  String exp = "0";
  String point = "0";
  String price1 = '0';
  String price2 = '0';
  String phone = "";
  String referrer_today = '0';
  String coupon_num = '0';
  String referrer_month = '0';
  String num_today = '0';
  String num_month = '0';

  String commission_all = '0';
  String commission_wait = '0';
  String commission_finish = '0';
  String alipay_account;
  Map user_msg = new Map();
  Map user_detail = new Map();
  @override
  Widget build(BuildContext context) {
    ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
    return new Scaffold(
      body: AnnotatedRegion<SystemUiOverlayStyle>(
        value: isVip == false
            ? SystemUiOverlayStyle.dark
            : SystemUiOverlayStyle.light,
        child: loginStatusCode == 106
            ? Container(
                alignment: Alignment.center,
                child: Container(
                  decoration: new BoxDecoration(
                      color: Color.fromARGB(255, 255, 140, 16),
                      borderRadius: BorderRadius.circular(
                          ScreenUtil.getInstance().setHeight(DP_80))),
                  child: new FlatButton(
                    child: new Padding(
                      padding: EdgeInsets.all(0.0),
                      child: new Text(
                        "请先登录",
                        style: new TextStyle(
                            color: Colors.white,
                            fontSize: ScreenUtil.getInstance()
                                .setSp(NORMAL_FONT_SIZE)),
                      ),
                    ),
                    onPressed: () {
                      Navigator.of(context).pushNamed('login');
                    },
                  ),
                ))
            : new EasyRefresh(
                header: MaterialHeader(),
                controller: _controller,
                onRefresh: () async {
                  getString(TOKEN).then((value) {
                    if (value == null) {
                      Navigator.of(context).pushNamed('login');
                    } else {
                      token = value;
                      getUserInfo();
                      getStatistics();
                    }
                  });
                },
                child: new Container(
                  child: Stack(
                    children: <Widget>[
                      Column(
                        children: <Widget>[
                          Container(
                              width: double.infinity,
                              height:
                                  ScreenUtil.getInstance().setHeight(DP_320),
                              padding: EdgeInsets.fromLTRB(
                                  ScreenUtil.getInstance().setWidth(DP_50),
                                  kWindowstateHeight +
                                      ScreenUtil.getInstance().setHeight(DP_30),
                                  ScreenUtil.getInstance().setWidth(DP_40),
                                  0),
                              decoration: BoxDecoration(
                                color: Colors.white,
                                image: DecorationImage(
                                    image: AssetImage(
                                        'images/user_dianzhu_bg.png'),
                                    fit: BoxFit.cover),
                              ),
                              child: Column(
                                children: <Widget>[
                                  Row(
                                    mainAxisAlignment: MainAxisAlignment.end,
                                    crossAxisAlignment:
                                        CrossAxisAlignment.center,
                                    children: <Widget>[
                                      GestureDetector(
                                        child:
                                            //  isVip == true?
                                            Image.asset(
                                                'images/icon_nav_news.png'),
                                        // : Image.asset('images/xiaoxi_gray.png'),
                                        onTap: () {
                                          Navigator.of(context).push(
                                              new MaterialPageRoute(
                                                  builder: (context) {
                                            return new InformNewsPage();
                                          }));
                                        },
                                      ),
                                      Container(
                                        width: DP_15,
                                      ),
                                      GestureDetector(
                                          child:
                                              // isVip == true?
                                              Image.asset(
                                                  'images/icon_nav_setup.png'),
                                          // : Image.asset('images/set_gray.png'),
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (context) {
                                              return new SystemPage();
                                            }));
                                          })
                                    ],
                                  ),
                                  Row(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.center,
                                    children: <Widget>[
                                      GestureDetector(
                                        child: ClipOval(
                                            child: avatar == null ||
                                                    avatar == ''
                                                ? Image.asset(
                                                    "images/logo.png",
                                                    fit: BoxFit.cover,
                                                    width:
                                                        ScreenUtil.getInstance()
                                                            .setWidth(DP_120),
                                                    height:
                                                        ScreenUtil.getInstance()
                                                            .setWidth(DP_120),
                                                  )
                                                : CachedNetworkImage(
                                                    width:
                                                        ScreenUtil.getInstance()
                                                            .setWidth(DP_120),
                                                    height:
                                                        ScreenUtil.getInstance()
                                                            .setWidth(DP_120),
                                                    fit: BoxFit.cover,
                                                    imageUrl: avatar,
                                                    placeholder: (context,
                                                            url) =>
                                                        Image.asset(
                                                            'images/pic_default.png',
                                                            width: ScreenUtil
                                                                    .getInstance()
                                                                .setWidth(
                                                                    DP_120),
                                                            height: ScreenUtil
                                                                    .getInstance()
                                                                .setWidth(
                                                                    DP_120)),
                                                    errorWidget: (context, url,
                                                            error) =>
                                                        Image.asset(
                                                            'images/pic_default.png',
                                                            width: ScreenUtil
                                                                    .getInstance()
                                                                .setWidth(
                                                                    DP_120),
                                                            height: ScreenUtil
                                                                    .getInstance()
                                                                .setWidth(
                                                                    DP_120)),
                                                  )),
                                        onTap: () {
                                          Navigator.of(context).push(
                                              new MaterialPageRoute(
                                                  builder: (context) {
                                            return new SystemPage();
                                          }));
                                        },
                                      ),
                                      Container(
                                        width: DP_10,
                                      ),
                                      Column(
                                        crossAxisAlignment:
                                            CrossAxisAlignment.start,
                                        children: <Widget>[
                                          Row(
                                            children: <Widget>[
                                              Text(userName,
                                                  style: TextStyle(
                                                      fontSize: ScreenUtil
                                                              .getInstance()
                                                          .setSp(
                                                              BIG2_FONT_SIZE),
                                                      color:
                                                          // isVip == true
                                                          //     ?
                                                          Colors.white
                                                      // : Colors.black
                                                      )),
                                              GestureDetector(
                                                onTap: () {
                                                  // Navigator.of(context).push(
                                                  //     new MaterialPageRoute(
                                                  //         builder: (context) {
                                                  //   return new VipCenterPage(
                                                  //     level: 1,
                                                  //   );
                                                  // }));
                                                },
                                                child: Container(
                                                    // decoration: BoxDecoration(
                                                    //     borderRadius:
                                                    //         BorderRadius.circular(5),
                                                    //     color: Colors.amberAccent),
                                                    padding: EdgeInsets.fromLTRB(
                                                        ScreenUtil.getInstance()
                                                            .setHeight(DP_10),
                                                        1,
                                                        ScreenUtil.getInstance()
                                                            .setHeight(DP_10),
                                                        1),
                                                    margin: EdgeInsets.fromLTRB(
                                                        ScreenUtil.getInstance()
                                                            .setHeight(DP_10),
                                                        0,
                                                        ScreenUtil.getInstance()
                                                            .setHeight(DP_10),
                                                        0),
                                                    child: Container(
                                                        child: Text(
                                                          group_name,
                                                          style: TextStyle(
                                                              fontSize: ScreenUtil
                                                                      .getInstance()
                                                                  .setSp(
                                                                      MINI_FONT_SIZE),
                                                              color: white),
                                                        ),
                                                        decoration:
                                                            BoxDecoration(
                                                          border: Border.all(
                                                              width: 1,
                                                              color: white),
                                                        ))),
                                              )
                                            ],
                                          ),
                                          Container(
                                            height: DP_8,
                                          ),
                                          isVip == true
                                              ? Container(
                                                  padding: EdgeInsets.fromLTRB(
                                                      0,
                                                      1,
                                                      ScreenUtil.getInstance()
                                                          .setWidth(DP_15),
                                                      1),
                                                  // decoration: BoxDecoration(
                                                  //     border: Border.all(
                                                  //         color: Colors.white, width: 1),
                                                  //     borderRadius:
                                                  //         BorderRadius.circular(DP_10)),
                                                  child: Row(
                                                    children: <Widget>[
                                                      // Image.asset(
                                                      //   "images/icon_signin.png",
                                                      //   scale: 1.2,
                                                      // ),
                                                      // Container(
                                                      //   width: 5,
                                                      // ),
                                                      Text('邀请码:' + code,
                                                          style: TextStyle(
                                                              fontSize: ScreenUtil
                                                                      .getInstance()
                                                                  .setSp(
                                                                      MINI_FONT_SIZE),
                                                              color: Colors
                                                                  .white)),
                                                    ],
                                                  ),
                                                )
                                              : Container(),
                                          Container(
                                            height: DP_8,
                                          ),
                                          Row(
                                            children: <Widget>[
                                              // Image.asset(
                                              //   "images/icon_signin.png",
                                              //   scale: 1.2,
                                              // ),
                                              // Container(
                                              //   width: 5,
                                              // ),
                                              Text('成长值:' + exp + '/5000',
                                                  style: TextStyle(
                                                      fontSize: ScreenUtil
                                                              .getInstance()
                                                          .setSp(
                                                              MINI_FONT_SIZE),
                                                      color:
                                                          //  isVip == true?
                                                          Colors.white
                                                      // : Colors.black
                                                      )),
                                              Container(
                                                width: 5,
                                              ),
                                              // 条形进度条
                                              Column(
                                                children: <Widget>[
                                                  Container(
                                                    padding: EdgeInsets.all(2),
                                                    decoration: BoxDecoration(
                                                        image: DecorationImage(
                                                            image: AssetImage(
                                                                'images/tishi_dianzhu.png'),
                                                            fit: BoxFit.fill)),
                                                    child: Text(
                                                      ' ' +
                                                          (double.parse(exp) /
                                                                  5000 *
                                                                  100)
                                                              .toString() +
                                                          '% ',
                                                      style: TextStyle(
                                                          color: Colors.red,
                                                          fontSize: ScreenUtil
                                                                  .getInstance()
                                                              .setSp(18)),
                                                    ),
                                                  ),
                                                  Container(
                                                    height: 1,
                                                  ),
                                                  // tishi_dianzhu
                                                  new Container(
                                                    decoration: BoxDecoration(
                                                        color: Color.fromRGBO(
                                                            237, 199, 146, 1),
                                                        borderRadius:
                                                            BorderRadius
                                                                .circular(2)),
                                                    //限制进度条的高度
                                                    height: 4.0,
                                                    //限制进度条的宽度
                                                    width:
                                                        ScreenUtil.getInstance()
                                                            .setWidth(200),
                                                    child:
                                                        new LinearProgressIndicator(
                                                            //0~1的浮点数，用来表示进度多少;如果 value 为 null 或空，则显示一个动画，否则显示一个定值
                                                            value: double.parse(
                                                                    exp) /
                                                                5000,
                                                            //背景颜色
                                                            backgroundColor:
                                                                Color.fromRGBO(
                                                                    237,
                                                                    199,
                                                                    146,
                                                                    1),
                                                            //进度颜色
                                                            valueColor:
                                                                new AlwaysStoppedAnimation<
                                                                        Color>(
                                                                    Colors
                                                                        .white)),
                                                  ),
                                                ],
                                              )
                                            ],
                                          ),
                                        ],
                                      )
                                    ],
                                  ),
                                  Container(
                                      height: ScreenUtil.getInstance()
                                          .setHeight(DP_10)),
                                ],
                              )),
                          Container(
                              height:
                                  ScreenUtil.getInstance().setHeight(DP_15)),
                          Offstage(
                            offstage: phone == "17768110717",
                            child: isVip == true ? initVipNum() : Container(),
                          ),
                          Offstage(
                            offstage: phone == "17768110717",
                            child: isVip == true ? initVipMoney() : Container(),
                          ),
                          isVip == true ? initVipTool() : Container(),
                          Offstage(
                            offstage: phone == "17768110717",
                            child:
                                isVip == true ? Container() : initNormalNum(),
                          ),
                          Offstage(
                              offstage: phone == "17768110717",
                              child: group_id != '1' && group_id != '2'
                                  ? Container(
                                      width: double.infinity,
                                      margin: EdgeInsets.fromLTRB(
                                          ScreenUtil.getInstance()
                                              .setWidth(DP_20),
                                          0,
                                          ScreenUtil.getInstance()
                                              .setWidth(DP_20),
                                          ScreenUtil.getInstance()
                                              .setWidth(DP_20)),
                                      height: ScreenUtil.getInstance()
                                          .setHeight(DP_120),
                                      decoration: BoxDecoration(
                                        borderRadius: BorderRadius.only(
                                            topLeft: Radius.circular(10),
                                            topRight: Radius.circular(10)),
                                        image: DecorationImage(
                                            image: AssetImage(
                                                "images/shengji_bg.png"),
                                            fit: BoxFit.fitHeight),
                                      ),
                                      child: Row(children: <Widget>[
                                        Expanded(
                                          flex: 1,
                                          child: Container(
                                            alignment: Alignment.topLeft,
                                            child: Column(
                                              children: <Widget>[
                                                Container(
                                                  margin: EdgeInsets.fromLTRB(
                                                      kMargin40, 7, 0, 0),
                                                  alignment:
                                                      Alignment.centerLeft,
                                                  child: Text(
                                                    "升级店主",
                                                    textAlign: TextAlign.left,
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                NORMAL_FONT_SIZE *
                                                                    1.1),
                                                        color: Color.fromRGBO(
                                                            119, 84, 38, 1)),
                                                  ),
                                                ),
                                                Container(),
                                                Container(
                                                  margin: EdgeInsets.fromLTRB(
                                                      kMargin40, 5, 0, 0),
                                                  alignment:
                                                      Alignment.centerLeft,
                                                  child: Text(
                                                      "仅需¥" +
                                                          (group_id == '1'
                                                              ? price1
                                                              : price2) +
                                                          "，平均每年可省3600元",
                                                      style: TextStyle(
                                                          fontSize: ScreenUtil
                                                                  .getInstance()
                                                              .setSp(
                                                                  MINI_FONT_SIZE),
                                                          color: Color.fromRGBO(
                                                              119, 84, 38, 1))),
                                                )
                                              ],
                                            ),
                                          ),
                                        ),
                                        Container(
                                          margin: EdgeInsets.fromLTRB(
                                              0,
                                              0,
                                              ScreenUtil.getInstance()
                                                  .setWidth(DP_40),
                                              0),
                                          child: RaisedButton(
                                            child: Text('立即省钱',
                                                style: TextStyle(
                                                  fontSize:
                                                      ScreenUtil.getInstance()
                                                          .setSp(
                                                              SMALL_FONT_SIZE),
                                                )),
                                            textColor: Colors.white,
                                            elevation: 20,
                                            shape: RoundedRectangleBorder(
                                                borderRadius:
                                                    BorderRadius.circular(20)),
                                            color:
                                                Color.fromRGBO(119, 84, 38, 1),
                                            onPressed: () {
                                              Navigator.of(context).push(
                                                  new MaterialPageRoute(
                                                      builder: (context) {
                                                return new BecomeShopperPage();
                                              }));
                                            },
                                          ),
                                        )
                                        //  )
                                      ]))
                                  : Container()),
                          Container(
                            padding: EdgeInsets.all(
                                ScreenUtil.getInstance().setWidth(DP_20)),
                            width: double.infinity,
                            margin: EdgeInsets.fromLTRB(
                                ScreenUtil.getInstance().setWidth(DP_20),
                                0,
                                ScreenUtil.getInstance().setWidth(DP_20),
                                ScreenUtil.getInstance().setWidth(DP_20)),
                            decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(DP_10),
                                color: Colors.white),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: <Widget>[
                                Container(
                                  child: Row(
                                    children: <Widget>[
                                      Expanded(
                                        child: Text('我的订单',
                                            style: TextStyle(
                                                fontSize:
                                                    ScreenUtil.getInstance()
                                                        .setSp(
                                                            NORMAL_FONT_SIZE),
                                                color: Colors.black)),
                                      ),
                                      GestureDetector(
                                        behavior: HitTestBehavior.opaque,
                                        onTap: () {
                                          Navigator.of(context).push(
                                              new MaterialPageRoute(
                                                  builder: (context) {
                                            return new OrderPage(index: 0);
                                          }));
                                        },
                                        child: Text('查看全部 >',
                                            style: TextStyle(
                                                fontSize:
                                                    ScreenUtil.getInstance()
                                                        .setSp(SMALL_FONT_SIZE),
                                                color: Colors.grey)),
                                      )
                                    ],
                                  ),
                                ),

                                Container(
                                    height: ScreenUtil.getInstance()
                                        .setHeight(DP_15)),
                                // Container(
                                //   height: 1,
                                //   color: f0Color,
                                // ),
                                Padding(
                                  padding: EdgeInsets.fromLTRB(
                                      0,
                                      ScreenUtil.getInstance().setHeight(DP_30),
                                      0,
                                      ScreenUtil.getInstance()
                                          .setHeight(DP_30)),
                                  child: Row(
                                    children: <Widget>[
                                      Expanded(
                                        child: GestureDetector(
                                          behavior: HitTestBehavior.opaque,
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (context) {
                                              return new OrderPage(index: 1);
                                            }));
                                          },
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/mine_order_daifukuan.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('待付款',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                        ),
                                      ),
                                      Expanded(
                                        child: GestureDetector(
                                          behavior: HitTestBehavior.opaque,
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (context) {
                                              return new OrderPage(index: 2);
                                            }));
                                          },
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/mine_order_daifahuo.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('待发货',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                        ),
                                      ),
                                      Expanded(
                                        child: new GestureDetector(
                                          behavior: HitTestBehavior.opaque,
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/mine_order_daishouhuo.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('待收货',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (context) {
                                              return new OrderPage(index: 3);
                                            }));
                                          },
                                        ),
                                      ),
                                      Expanded(
                                        child: GestureDetector(
                                          behavior: HitTestBehavior.opaque,
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/mine_order_pingjia.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('评价有礼',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (context) {
                                              return new OrderPage(index: 4);
                                            }));
                                          },
                                        ),
                                      ),
                                      Expanded(
                                        child: GestureDetector(
                                          behavior: HitTestBehavior.opaque,
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (context) {
                                              return new OrderPage(index: 6);
                                            }));
                                          },
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/mine_order_tuihuo.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('退货退款',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.all(
                                ScreenUtil.getInstance().setWidth(DP_20)),
                            width: double.infinity,
                            margin: EdgeInsets.fromLTRB(
                                ScreenUtil.getInstance().setWidth(DP_20),
                                0,
                                ScreenUtil.getInstance().setWidth(DP_20),
                                ScreenUtil.getInstance().setWidth(DP_20)),
                            decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(DP_10),
                                color: Colors.white),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: <Widget>[
                                Text('其他服务',
                                    style: TextStyle(
                                        fontSize: ScreenUtil.getInstance()
                                            .setSp(NORMAL_FONT_SIZE),
                                        color: Colors.black)),
                                Container(
                                    height: ScreenUtil.getInstance()
                                        .setHeight(DP_15)),
                                // Container(
                                //   height: 1,
                                //   color: f0Color,
                                // ),
                                Padding(
                                  padding: EdgeInsets.fromLTRB(
                                      0,
                                      ScreenUtil.getInstance().setHeight(DP_30),
                                      0,
                                      ScreenUtil.getInstance()
                                          .setHeight(DP_30)),
                                  child: Row(
                                    children: <Widget>[
                                      Expanded(
                                        child: GestureDetector(
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (context) {
                                              return new MySignPage();
                                            }));
                                          },
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/mine_user_jifen.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('我的积分',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                        ),
                                      ),
                                      isVip == true
                                          ? Expanded(
                                              child: new GestureDetector(
                                                child: Center(
                                                  child: Column(
                                                    children: <Widget>[
                                                      Image.asset(
                                                        "images/mine_user_qianbao.png",
                                                      ),
                                                      Container(
                                                        height: ScreenUtil
                                                                .getInstance()
                                                            .setHeight(DP_10),
                                                      ),
                                                      Text('钱包',
                                                          style: TextStyle(
                                                              fontSize: ScreenUtil
                                                                      .getInstance()
                                                                  .setSp(
                                                                      MINI_FONT_SIZE),
                                                              color: Colors
                                                                  .black87)),
                                                    ],
                                                  ),
                                                ),
                                                onTap: () {
                                                  Navigator.of(context).push(
                                                      new MaterialPageRoute(
                                                          builder: (context) {
                                                    return new MyWalletPage();
                                                  }));
                                                },
                                              ),
                                            )
                                          : Expanded(
                                              child: GestureDetector(
                                                onTap: () {
                                                  Navigator.of(context).push(
                                                      new MaterialPageRoute(
                                                          builder: (context) {
                                                    return new PointPage();
                                                  }));
                                                },
                                                child: Center(
                                                  child: Column(
                                                    children: <Widget>[
                                                      Image.asset(
                                                        "images/mine_user_jifen.png",
                                                      ),
                                                      Container(
                                                        height: ScreenUtil
                                                                .getInstance()
                                                            .setHeight(DP_10),
                                                      ),
                                                      Text('积分商城',
                                                          style: TextStyle(
                                                              fontSize: ScreenUtil
                                                                      .getInstance()
                                                                  .setSp(
                                                                      MINI_FONT_SIZE),
                                                              color: Colors
                                                                  .black87)),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                            ),
                                      Expanded(
                                        child: GestureDetector(
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/mine_user_quan.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('优惠券',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (context) {
                                              return new MyCouponPage();
                                            }));
                                          },
                                        ),
                                      ),
                                      Expanded(
                                        child: GestureDetector(
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (context) {
                                              return new CollectPage();
                                            }));
                                          },
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/mine_user_shoucang.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('我的收藏',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                                Padding(
                                  padding: EdgeInsets.fromLTRB(
                                      0,
                                      ScreenUtil.getInstance().setHeight(DP_10),
                                      0,
                                      ScreenUtil.getInstance()
                                          .setHeight(DP_30)),
                                  child: Row(
                                    children: <Widget>[
                                      Expanded(
                                        child: new GestureDetector(
                                          onTap: () {
                                            if (APPLIC.userInfoMap == null) {
                                              return;
                                            }
                                            if (Platform.isAndroid) {
                                              Navigator.of(context)
                                                  .push<String>(
                                                      MaterialPageRoute(
                                                          builder: (context) {
                                                return new LocalNavWebWidget(
                                                    "http://kf.0731app.cn/index/index/home?visiter_id=" +
                                                        APPLIC.userInfoMap[
                                                                'user_msg']
                                                                ['uid']
                                                            .toString() +
                                                        "&visiter_name=" +
                                                        APPLIC.userInfoMap[
                                                                'user_msg']
                                                                ['phone']
                                                            .toString() +
                                                        "&avatar=&business_id=3&groupid=0&special=7",
                                                    "客服");
                                              })).then((value) {});
                                              return;
                                            }
                                            Navigator.of(context).push<String>(
                                                MaterialPageRoute(
                                                    builder: (context) {
                                              return OrderCommentPage(
                                                  url: "http://kf.0731app.cn/index/index/home?visiter_id=" +
                                                      APPLIC.userInfoMap[
                                                              'user_msg']
                                                              ['uid']
                                                          .toString() +
                                                      "&visiter_name=" +
                                                      APPLIC.userInfoMap[
                                                              'user_msg']
                                                              ['phone']
                                                          .toString() +
                                                      "&avatar=&business_id=3&groupid=0&special=7");
                                            })).then((value) {});
                                          },
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/mine_user_kefu.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('我的客服',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                        ),
                                      ),
                                      Expanded(
                                          child: GestureDetector(
                                        onTap: () {
                                          Navigator.of(context).push(
                                              new MaterialPageRoute(
                                                  builder: (context) {
                                            return new MyReceiptPage();
                                          }));
                                        },
                                        child: Center(
                                          child: Column(
                                            children: <Widget>[
                                              Image.asset(
                                                "images/mine_user_fapiao.png",
                                              ),
                                              Container(
                                                height: ScreenUtil.getInstance()
                                                    .setHeight(DP_10),
                                              ),
                                              Text('发票管理',
                                                  style: TextStyle(
                                                      fontSize: ScreenUtil
                                                              .getInstance()
                                                          .setSp(
                                                              MINI_FONT_SIZE),
                                                      color: Colors.black87)),
                                            ],
                                          ),
                                        ),
                                      )),
                                      Expanded(
                                        child: GestureDetector(
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (context) {
                                              return new MyAddressPage(type: 0);
                                            }));
                                          },
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/mine_user_adress.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('收货地址',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                        ),
                                      ),
                                      Expanded(
                                        child: GestureDetector(
                                          onTap: () {
                                            goToMyShop();
                                          },
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/mine_user_dianpu.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('所在店铺',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                                Padding(
                                  padding: EdgeInsets.fromLTRB(
                                      0,
                                      ScreenUtil.getInstance().setHeight(DP_30),
                                      0,
                                      ScreenUtil.getInstance()
                                          .setHeight(DP_30)),
                                  child: Row(
                                    children: <Widget>[
                                      isVip == true
                                          ? Expanded(
                                              child: GestureDetector(
                                                onTap: () {
                                                  Navigator.of(context).push(
                                                      new MaterialPageRoute(
                                                          builder: (context) {
                                                    return new PointPage();
                                                  }));
                                                },
                                                child: Center(
                                                  child: Column(
                                                    children: <Widget>[
                                                      Image.asset(
                                                        "images/mine_user_jifen.png",
                                                      ),
                                                      Container(
                                                        height: ScreenUtil
                                                                .getInstance()
                                                            .setHeight(DP_10),
                                                      ),
                                                      Text('积分商城',
                                                          style: TextStyle(
                                                              fontSize: ScreenUtil
                                                                      .getInstance()
                                                                  .setSp(
                                                                      MINI_FONT_SIZE),
                                                              color: Colors
                                                                  .black87)),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                            )
                                          : Container(),
                                      Expanded(
                                        child: new GestureDetector(
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/tool_g.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('关于我们',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                          onTap: () {
                                            Navigator.of(context).push(
                                                MaterialPageRoute(
                                                    builder: (context) {
                                              return new ArticleDetailPage(
                                                article_id: '1',
                                              );
                                            }));
                                          },
                                        ),
                                      ),
                                      Expanded(
                                        child: GestureDetector(
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/tool_e.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('意见反馈',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (context) {
                                              return new FormPage(
                                                type: 1,
                                              );
                                            }));
                                          },
                                        ),
                                      ),
                                      Expanded(
                                        child: GestureDetector(
                                          onTap: () {
                                            Navigator.of(context).push(
                                                new MaterialPageRoute(
                                                    builder: (context) {
                                              return new FormPage();
                                            }));
                                          },
                                          child: Center(
                                            child: Column(
                                              children: <Widget>[
                                                Image.asset(
                                                  "images/tool_c.png",
                                                ),
                                                Container(
                                                  height:
                                                      ScreenUtil.getInstance()
                                                          .setHeight(DP_10),
                                                ),
                                                Text('商务合作',
                                                    style: TextStyle(
                                                        fontSize: ScreenUtil
                                                                .getInstance()
                                                            .setSp(
                                                                MINI_FONT_SIZE),
                                                        color: Colors.black87)),
                                              ],
                                            ),
                                          ),
                                        ),
                                      ),
                                      isVip == true
                                          ? Container()
                                          : Expanded(
                                              child: Container(),
                                            )
                                    ],
                                  ),
                                ),
                              ],
                            ),
                          )
                        ],
                      )
                    ],
                  ),
                ),
              ),
      ),
    );
  }

  initNormalNum() {
    //普通级别订单数量统计
    return Container(
      padding: EdgeInsets.fromLTRB(
          ScreenUtil.getInstance().setWidth(DP_20),
          ScreenUtil.getInstance().setWidth(DP_30),
          ScreenUtil.getInstance().setWidth(DP_20),
          ScreenUtil.getInstance().setWidth(DP_30)),
      margin: EdgeInsets.fromLTRB(
          ScreenUtil.getInstance().setWidth(DP_20),
          0,
          ScreenUtil.getInstance().setWidth(DP_20),
          ScreenUtil.getInstance().setWidth(DP_20)),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(DP_10), color: Colors.white),
      child: Row(
        children: <Widget>[
          Expanded(
              child: GestureDetector(
            onTap: () {
              Navigator.of(context)
                  .push(new MaterialPageRoute(builder: (context) {
                return new MyCouponPage();
              }));
            },
            child: Center(
              child: Column(
                children: <Widget>[
                  Text(coupon_num,
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(BIG_FONT_SIZE),
                          color: Colors.black)),
                  Container(
                    height: ScreenUtil.getInstance().setHeight(DP_10),
                  ),
                  Text('优惠券',
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(MINI_FONT_SIZE),
                          color: Colors.black87)),
                ],
              ),
            ),
          )),
          // Expanded(
          //     child: GestureDetector(
          //   onTap: () {
          //     Navigator.of(context)
          //         .push(new MaterialPageRoute(builder: (context) {
          //       return new MyEarnPage();
          //     }));
          //   },
          //   child: Center(
          //     child: Column(
          //       children: <Widget>[
          //         Text(balance,
          //             style: TextStyle(
          //                 fontSize:
          //                     ScreenUtil.getInstance().setSp(BIG_FONT_SIZE),
          //                 color: Colors.black)),
          //         Container(
          //           height: ScreenUtil.getInstance().setHeight(DP_10),
          //         ),
          //         Text('余额',
          //             style: TextStyle(
          //                 fontSize:
          //                     ScreenUtil.getInstance().setSp(MINI_FONT_SIZE),
          //                 color: Colors.black87)),
          //       ],
          //     ),
          //   ),
          // )),
          Expanded(
              child: GestureDetector(
            onTap: () {
              Navigator.of(context)
                  .push(new MaterialPageRoute(builder: (context) {
                return new PointListPage();
              }));
            },
            child: Center(
              child: Column(
                children: <Widget>[
                  Text(point,
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(BIG_FONT_SIZE),
                          color: Colors.black)),
                  Container(
                    height: ScreenUtil.getInstance().setHeight(DP_10),
                  ),
                  Text('积分',
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(MINI_FONT_SIZE),
                          color: Colors.black87)),
                ],
              ),
            ),
          )),
        ],
      ),
    );
  }

  initVipNum() {
    //店主级别订单数量统计
    return Container(
      padding: EdgeInsets.fromLTRB(
          ScreenUtil.getInstance().setWidth(DP_20),
          ScreenUtil.getInstance().setWidth(DP_30),
          ScreenUtil.getInstance().setWidth(DP_20),
          ScreenUtil.getInstance().setWidth(DP_30)),
      margin: EdgeInsets.fromLTRB(
          ScreenUtil.getInstance().setWidth(DP_20),
          0,
          ScreenUtil.getInstance().setWidth(DP_20),
          ScreenUtil.getInstance().setWidth(DP_20)),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(DP_10), color: Colors.white),
      child: Row(
        children: <Widget>[
          Expanded(
            child: Center(
              child: Column(
                children: <Widget>[
                  Text(referrer_today,
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(BIG_FONT_SIZE),
                          color: Colors.black)),
                  Container(
                    height: ScreenUtil.getInstance().setHeight(DP_10),
                  ),
                  Text('今日邀请',
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(MINI_FONT_SIZE),
                          color: Colors.black87)),
                ],
              ),
            ),
          ),
          Expanded(
            child: Center(
              child: Column(
                children: <Widget>[
                  Text(referrer_month,
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(BIG_FONT_SIZE),
                          color: Colors.black)),
                  Container(
                    height: ScreenUtil.getInstance().setHeight(DP_10),
                  ),
                  Text('本月邀请',
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(MINI_FONT_SIZE),
                          color: Colors.black87)),
                ],
              ),
            ),
          ),
          Expanded(
              child: GestureDetector(
            onTap: () {},
            child: Center(
              child: Column(
                children: <Widget>[
                  Text(num_today,
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(BIG_FONT_SIZE),
                          color: Colors.black)),
                  Container(
                    height: ScreenUtil.getInstance().setHeight(DP_10),
                  ),
                  Text('今日订单',
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(MINI_FONT_SIZE),
                          color: Colors.black87)),
                ],
              ),
            ),
          )),
          Expanded(
            child: Center(
              child: Column(
                children: <Widget>[
                  Text(num_month,
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(BIG_FONT_SIZE),
                          color: Colors.black)),
                  Container(
                    height: ScreenUtil.getInstance().setHeight(DP_10),
                  ),
                  Text('本月订单',
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(MINI_FONT_SIZE),
                          color: Colors.black87)),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  initVipMoney() {
    //店主级别累计金额收入模块
    return Container(
        padding: EdgeInsets.fromLTRB(
            0, ScreenUtil.getInstance().setWidth(DP_20), 0, 0),
        margin: EdgeInsets.all(ScreenUtil.getInstance().setWidth(DP_20)),
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(DP_10), color: Colors.white),
        child: Column(children: <Widget>[
          Row(children: <Widget>[
            Container(
              margin: EdgeInsets.fromLTRB(
                  ScreenUtil.getInstance().setWidth(DP_20),
                  0,
                  ScreenUtil.getInstance().setWidth(DP_10),
                  0),
              child: Image.asset('images/dianzhu_jinbi.png'),
            ),
            Expanded(
              child: Text(
                '累计已赚',
                style: TextStyle(
                    fontSize: ScreenUtil.getInstance().setSp(BIG_FONT_SIZE)),
              ),
            ),
            Container(
                margin: EdgeInsets.fromLTRB(
                    0, 0, ScreenUtil.getInstance().setWidth(DP_20), 0),
                child: Align(child: Image.asset('images/yiwen.png'))),
          ]),
          Container(
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(DP_10),
                  color: Colors.white),
              alignment: Alignment.centerLeft,
              margin: EdgeInsets.fromLTRB(
                  ScreenUtil.getInstance().setWidth(DP_20),
                  ScreenUtil.getInstance().setWidth(DP_20),
                  0,
                  ScreenUtil.getInstance().setWidth(DP_10)),
              child: Row(
                children: <Widget>[
                  Expanded(
                      flex: 3,
                      child: RichText(
                        text: TextSpan(
                            text: commission_all,
                            style: TextStyle(
                                color: Colors.black,
                                fontSize: ScreenUtil.getInstance()
                                    .setSp(BIG_FONT_SIZE * 1.5)),
                            children: <TextSpan>[
                              TextSpan(
                                  text: '元',
                                  style: TextStyle(
                                      color: Colors.black,
                                      fontSize: ScreenUtil.getInstance()
                                          .setSp(BIG_FONT_SIZE),
                                      fontWeight: FontWeight.w500)),
                            ]),
                      )),
                  Expanded(
                      // flex: 1,
                      child: Container(
                          child: GestureDetector(
                    child: Image(
                      image: AssetImage('images/icon_cashout.png'),
                    ),
                    onTap: () {
                      // if (alipay_account == null || alipay_account == 'null') {
                      //   Navigator.of(context)
                      //       .push(new MaterialPageRoute(builder: (context) {
                      //     return new BindZfbPage();
                      //   }));
                      // } else {
                      Navigator.of(context)
                          .push(new MaterialPageRoute(builder: (context) {
                        return new TXPage();
                      }));
                      // }
                      print('提现');
                    },
                  )))
                ],
              )
              // Text('0' + '元',
              // style: TextStyle(fontSize: BIG_FONT_SIZE, color: Colors.black))
              ),
          Container(
            height: 10,
            width: 1,
          ),
          Container(
              height: ScreenUtil.getInstance().setHeight(120),
              color: f0Color,
              child: Row(
                children: <Widget>[
                  Expanded(
                    child: Center(
                      child: Column(
                        children: <Widget>[
                          Container(
                            height: 8,
                            width: 1,
                          ),
                          Text('待确认佣金',
                              style: TextStyle(
                                  fontSize: ScreenUtil.getInstance()
                                      .setSp(MINI_FONT_SIZE),
                                  color: Colors.grey)),
                          Text(commission_wait,
                              style: TextStyle(
                                  fontSize: ScreenUtil.getInstance()
                                      .setSp(BIG_FONT_SIZE * 1.4),
                                  color: Colors.black)),
                        ],
                      ),
                    ),
                  ),
                  Expanded(
                    child: Center(
                      child: Column(
                        children: <Widget>[
                          Container(
                            height: 8,
                            width: 1,
                          ),
                          Text('已结算佣金',
                              style: TextStyle(
                                  fontSize: ScreenUtil.getInstance()
                                      .setSp(MINI_FONT_SIZE),
                                  color: Colors.grey)),
                          Text(commission_wait,
                              style: TextStyle(
                                  fontSize: ScreenUtil.getInstance()
                                      .setSp(BIG_FONT_SIZE * 1.4),
                                  color: Colors.black)),
                        ],
                      ),
                    ),
                  ),
                  Expanded(
                    child: Center(
                      child: Column(
                        children: <Widget>[
                          Container(
                            height: 8,
                            width: 1,
                          ),
                          Text('余额',
                              style: TextStyle(
                                  fontSize: ScreenUtil.getInstance()
                                      .setSp(MINI_FONT_SIZE),
                                  color: Colors.grey)),
                          Text(balance,
                              style: TextStyle(
                                  fontSize: ScreenUtil.getInstance()
                                      .setSp(BIG_FONT_SIZE * 1.4),
                                  color: Colors.black)),
                        ],
                      ),
                    ),
                  )
                ],
              )),
        ]));
  }

  initVipTool() {
    return Container(
      padding: EdgeInsets.fromLTRB(
          ScreenUtil.getInstance().setWidth(DP_20),
          ScreenUtil.getInstance().setWidth(DP_30),
          ScreenUtil.getInstance().setWidth(DP_20),
          ScreenUtil.getInstance().setWidth(DP_30)),
      margin: EdgeInsets.all(ScreenUtil.getInstance().setWidth(DP_20)),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(DP_10), color: Colors.white),
      child: Row(
        children: <Widget>[
          Expanded(
              child: GestureDetector(
            onTap: () {
              Navigator.of(context)
                  .push(new MaterialPageRoute(builder: (context) {
                return new MyEarnPage();
              }));
            },
            child: Center(
              child: Column(
                children: <Widget>[
                  Image.asset("images/mine_dz_shouyi.png"),
                  Text('我的收益',
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(MINI_FONT_SIZE),
                          color: Colors.black87)),
                ],
              ),
            ),
          )),
          Expanded(
            child: GestureDetector(
                onTap: () {
                  Navigator.of(context)
                      .push(new MaterialPageRoute(builder: (context) {
                    return new TeamOrderPage(
                      index: 0,
                    );
                  }));
                },
                child: Center(
                  child: Column(
                    children: <Widget>[
                      Image.asset("images/mine_dz_dingdan.png"),
                      Text('团队订单',
                          style: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(MINI_FONT_SIZE),
                              color: Colors.black87)),
                    ],
                  ),
                )),
          ),
          Expanded(
              child: GestureDetector(
            onTap: () {
              Navigator.of(context)
                  .push(new MaterialPageRoute(builder: (context) {
                return new TeamMarketPage();
              }));
            },
            child: Center(
              child: Column(
                children: <Widget>[
                  Image.asset("images/mine_dz_tuandui.png"),
                  Text('我的团队',
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(MINI_FONT_SIZE),
                          color: Colors.black87)),
                ],
              ),
            ),
          )),
          Expanded(
              child: GestureDetector(
            onTap: () {
              Navigator.of(context)
                  .push(new MaterialPageRoute(builder: (context) {
                return new InviteFriendPage();
              }));
            },
            child: Center(
              child: Column(
                children: <Widget>[
                  Image.asset("images/mine_dz_yaoqing.png"),
                  Text('我的推广',
                      style: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(MINI_FONT_SIZE),
                          color: Colors.black87)),
                ],
              ),
            ),
          )),
        ],
      ),
    );
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    // TODO: implement didChangeAppLifecycleState
    super.didChangeAppLifecycleState(state);
    if (state == AppLifecycleState.resumed) {
      _getLoginMsg();
    }
  }

  @override
  void initState() {
    super.initState();
    _getLoginMsg();
    WidgetsBinding.instance.addObserver(this);
    APPLIC.eventBus.on<LoginEvent>().listen((event) {
      getString(TOKEN).then((value) {
        token = value;
        getUserInfo();
        getStatistics();
        getGoodMsg('1');
        getGoodMsg('2');
      });
    });
  }

  @override
  void dispose() {
    super.dispose();
    WidgetsBinding.instance.removeObserver(this); //销毁观察者
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) {
    return false;
  }

  void _getLoginMsg() async {
    getString(TOKEN).then((value) {
      if (value == null) {
        // Navigator.of(context).pushNamed('login');
        setState(() {
          loginStatusCode = 106;
        });
      } else {
        token = value;
        getUserInfo();
        getStatistics();
      }
    });
  }

  getGoodMsg(String goods_id) async {
    Map map = new Map();
    map['goods_id'] = goods_id;
    map['sign_type'] = createSignType(Api.URL_VIPGoods);
    print(map);
    Response<String> response =
        await HttpUtil().post(Api.URL_VIPGoods, data: getSign(map));
    Map userMap = json.decode(response.data);
    print(userMap);
    if (userMap['code'] == 1 && mounted) {
      setState(() {
        if (goods_id == '1') {
          //升级店主
          price1 = userMap['data']['goodsMsg']['price'].toString();
        }
        if (goods_id == '2') {
          //升级服务商
          price2 = userMap['data']['goodsMsg']['price'].toString();
        }
      });
    }
  }

  getStatistics() async {
    Map map = new Map();
    map['token'] = token;
    map['sign_type'] = createSignType(Api.URL_USER_Statistics);
    print(map);
    Response<String> response =
        await HttpUtil().post(Api.URL_USER_Statistics, data: getSign(map));
    Map userMap = json.decode(response.data);
    print('=========统计数据======');
    print(userMap);
    if (userMap['code'] == 1 && mounted) {
      setState(() {
        referrer_today = userMap['data']['referrer_today'].toString();
        referrer_month = userMap['data']['referrer_month'].toString();
        num_today = userMap['data']['orderStatistics']['num_today'].toString();
        num_month = userMap['data']['orderStatistics']['num_month'].toString();
        coupon_num = userMap['data']['coupon_num'].toString();
        commission_all =
            userMap['data']['orderStatistics']['commission_all'].toString();
        commission_wait =
            userMap['data']['orderStatistics']['commission_wait'].toString();
        commission_finish =
            userMap['data']['orderStatistics']['commission_finish'].toString();
      });
    }
  }

  getUserInfo() async {
    Map map = new Map();
    map['token'] = token;
    map['sign_type'] = createSignType(Api.URL_USER_GETMSG);
    print(map);
    Response<String> response =
        await HttpUtil().post(Api.URL_USER_GETMSG, data: getSign(map));
    Map userMap = json.decode(response.data);
    print(userMap);
    setState(() {
      loginStatusCode = userMap['code'];
    });
    if (userMap['code'] == 1 && mounted) {
      setState(() {
        APPLIC.userInfoMap = userMap['data'];
        userMap = userMap['data'];

        // user_msg = userMap['user_msg'];
        // user_detail = userMap['user_detail'];
        exp = userMap['user_msg']['exp'].toString();
        phone = userMap['user_msg']['phone'].toString();
        balance = userMap['user_msg']['balance'];
        alipay_account = userMap['user_msg']['alipay_account'];
        point = userMap['user_msg']['point'].toString();
        group_name = userMap['user_msg']['group_name'];
        userName = userMap['user_detail']['nickname'] == null
            ? userMap['user_msg']['phone']
            : userMap['user_detail']['nickname'];
        avatar = userMap['user_detail']['avatar'];
        code = userMap['user_msg']['auth_code'];
        isVip =
            userMap['user_msg']['group_id'].toString() == "1" ? false : true;
        group_id = userMap['user_msg']['group_id'].toString();
      });
    }
  }

  goToMyShop() async {
    Map map = new Map();
    map['token'] = token;
    map['sign_type'] = createSignType(Api.URL_USER_show_auth);
    Response<String> response =
        await HttpUtil().post(Api.URL_USER_show_auth, data: getSign(map));
    Map userMap = json.decode(response.data);
    print(userMap);
    if (userMap['code'] == 1 && mounted) {
      // if (userMap['data']['auth_code'] == null) {
      //   //跳转填写页面
      //   Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
      //     return new FillAuthCodePage();
      //   }));
      // } else {
      //跳转展示页面
      Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
        return new MyShopPage(token: token);
      }));
      // }
    }
  }
}
